// ignore_for_file: file_names, must_be_immutable, constant_identifier_names, slash_for_doc_comments, avoid_unnecessary_containers, prefer_const_constructors, unnecessary_cast, sized_box_for_whitespace, prefer_function_declarations_over_variables, overridden_fields, annotate_overrides, prefer_const_literals_to_create_immutables, unnecessary_null_comparison, deprecated_member_use, prefer_typing_uninitialized_variables

import 'package:mybase/base/tool/empty/FFEmpty.dart';

enum RStatus {
  result, //返回看起来正常，并有数据
  noData, //返回看起来正常，但没数据，或者收到操作失败。
  error, //指网络，错误
  timeout //指网络，超时了
}


abstract class IFFR<T> {
  /**提示语 */
  String? msg;
  /**状态码 */
  String? code;
  /**是否有下一页 */
  bool? haveNext;
  /**接口返回的时间戳 秒*/
  String? time;
  /**api返回的数据状态 */
  RStatus? rStatus;
  /**response header*/
  Map<String,dynamic>? responseHeader;
  /**是否包含指定的key的响应头*/
  bool containResponseHeader(String responseHeaderKey);
  /**返回的data */
  T? data;
  /**原始数据 */
  dynamic originalData;
}

class R<T> implements IFFR<T> {
  @override
  String? code;

  @override
  T? data;

  @override
  bool? haveNext;

  @override
  String? msg;

  @override
  String? time;

  @override
  RStatus? rStatus;

  @override
  var originalData;

  @override
  Map<String, dynamic>? responseHeader;

  R({
    this.msg,
    this.code,
    this.haveNext,
    this.rStatus,
    this.data,
    this.originalData,
    this.time,
    this.responseHeader,
  });

  @override
  bool containResponseHeader(String responseHeaderKey) {
    if (FFEmpty.mapIsEmpty(responseHeader)) {
      return false;
    }

    if (responseHeader!.containsKey(responseHeaderKey)) {
      return true;
    }

    return false;
  }
}


R api(){
  return R(msg: "请求",code: "1",haveNext: false,rStatus: RStatus.result,time: "1676972551");
}
